﻿package mortal.game.view.CollectExchange.other
{
    import __AS3__.vec.*;
    import mortal.game.cache.*;
    import mortal.game.resource.info.item.*;

    public class CollectExchangeDataGroup extends Object
    {
        private var _itemInfo:Vector.<ItemData>;
        public var needNum:int;
        public var dataItemList:Vector.<CollectExchangeDataItem>;
        public var leftTimes:int;
        public var maxTimes:int;
        public var id:int;

        public function CollectExchangeDataGroup()
        {
            return;
        }// end function

        public function get itemInfos() : Vector.<ItemData>
        {
            var _loc_1:int = 0;
            var _loc_2:ItemData = null;
            if (this._itemInfo == null)
            {
                this._itemInfo = new Vector.<ItemData>;
                _loc_1 = 0;
                while (_loc_1 < this.dataItemList.length)
                {
                    
                    _loc_2 = new ItemData(this.dataItemList[_loc_1].id);
                    _loc_2.extData = new Object();
                    _loc_2.extData["num"] = this.dataItemList[_loc_1].num;
                    this._itemInfo.push(_loc_2);
                    _loc_1++;
                }
            }
            return this._itemInfo;
        }// end function

        public function get itemNum() : int
        {
            if (this.dataItemList)
            {
                return this.dataItemList.length;
            }
            return 0;
        }// end function

        public function isSatisfyRecipe() : Boolean
        {
            var _loc_2:int = 0;
            var _loc_3:Boolean = false;
            if (this.leftTimes <= 0)
            {
                return false;
            }
            var _loc_1:int = 0;
            while (_loc_1 < this.needNum)
            {
                
                _loc_2 = this.dataItemList[_loc_1].id;
                _loc_3 = Cache.instance.pack.backPackCache.getItemByCode(_loc_2, true) == null ? (false) : (true);
                if (!_loc_3)
                {
                    return false;
                }
                _loc_1++;
            }
            return true;
        }// end function

    }
}
